-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Sets #3846
Add Sets #3846
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shaping up nicely! I think you'll also want to add the new operators to the Expr
typeclasses that define the smart constructors of the various Expr
s:
class ExprC r where |
-- | Helpful for filtering for Physical constraints. True if constraint is 'Physical'. | ||
isPhysC (Range Physical _) = True | ||
isPhysC _ = False | ||
isPhysRange (Range Physical _) = True | ||
isPhysRange _ = False | ||
|
||
isPhysElem (Elem Physical _) = True | ||
isPhysElem _ = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the differentiation needed between Range and Elem for this? Why are the isX
functions needed at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used for formatting constraints. I don't think a distinction between the two would need to be made here
Drasil/code/drasil-docLang/lib/Drasil/Sections/SpecificSystemDescription.hs
Lines 278 to 284 in eacde82
-- | Formats Physical Constraints into a 'Sentence'. | |
fmtPhys :: (Constrained c, Quantity c) => c -> Sentence | |
fmtPhys c = foldConstraints c $ filter isPhysC (c ^. constraints) | |
-- | Formats Software Constraints into a 'Sentence'. | |
fmtSfwr :: (Constrained c, Quantity c) => c -> Sentence | |
fmtSfwr c = foldConstraints c $ filter isSfwrC (c ^. constraints) |
Drasil/code/drasil-code/lib/Language/Drasil/Chunk/ConstraintMap.hs
Lines 22 to 28 in eacde82
-- | Returns a pair of a chunk and its physical constraints. | |
physLookup :: HasUID q => ConstraintCEMap -> q -> (q, [ConstraintCE]) | |
physLookup m q = constraintLookup q m (filter isPhysC) | |
-- | Returns a pair of a chunk and its software constraints. | |
sfwrLookup :: HasUID q => ConstraintCEMap -> q -> (q, [ConstraintCE]) | |
sfwrLookup m q = constraintLookup q m (filter isSfwrC) |
@@ -70,6 +70,18 @@ data UFuncVV = NegV | |||
data UFuncVN = Norm | Dim | |||
deriving Eq | |||
|
|||
-- | Set + Set -> Set | |||
data SSet = SUnion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the pattern below, I think this would be SSSBinOp
? Union is also associative, so you can build it similar to the other associative operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree ___BinOp
would probably be better. For Union I was thinking of doing
data AssocConcatOper = SUnion
deriving Eq
data ESSSet = SAdd | SRemove | ||
deriving Eq | ||
|
||
-- | Element + Set -> Bool | ||
data ESBSet = SContains | ||
deriving Eq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with above on naming.
@@ -109,7 +120,7 @@ data Expr where | |||
Case :: Completeness -> [(Expr, Relation)] -> Expr | |||
-- | Represents a matrix of expressions. | |||
Matrix :: [[Expr]] -> Expr | |||
|
|||
Set :: Expr -> Expr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor should take in a Set
(or list if we don't have an Ord
instance for Expr
) of Expr
s.
|
||
infer cxt (Set e) = | ||
case infer cxt e of | ||
Left sp -> if S.isBasicNumSpace sp then Left sp else Right (show sp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need to restrict ourselves to only numeric sets. For example, power sets and string sets are probably things we want. However, we can probably just admit anything in the set, so as long as the elements are of the same type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was left in by accident.
Have you also started on the conversion of the Exprs into GOOL? |
Yes I have started some of the conversions of expr in GOOL. I wanted to ensure I was on the right path before getting too deep into GOOL. |
It would be good to merge in changes from |
Closes #2655. WIP, I currently have created sets in expr.